<?php

class Auth extends MY_Controller {


    function index() {

        $this->layout->view('list_users',$data);
    }

    function register() {
        $this->layout->setLayout('theme1');

        $this->load->library('validation');
        $this->load->library('redux_auth');
        // Required Field Rules.
        $rules['username']	= "required";
        $rules['password']	= "required";
        $rules['password2'] 	= "required";
        $rules['email'] 		= "required";
        $rules['question'] 	= "required";
        $rules['answer'] 		= "required";

        $this->validation->set_rules($rules);

        // Required Field Names
        $fields['username'] 	= "Username";
        $fields['password'] 	= "Password";
        $fields['password2'] 	= "Confirm Password";
        $fields['email'] 		= "Email Address";
        $fields['question']		= "Secret Question";
        $fields['answer']		= "Secret Answer";

        $this->validation->set_fields($fields);

        if ($this->validation->run()) {
            // Validation Passed

            $redux = $this->redux_auth->register
                    (
                    $this->input->post('username'),
                    $this->input->post('password'),
                    $this->input->post('email'),
                    $this->input->post('question'),
                    $this->input->post('answer')
            );

            // The reason we put the method into a variable is so we can deal
            // with the different return messages.

            // I use a switch statement to deal with the different return
            // messages produced by the registration method.

            switch ($redux) {
                case 'REGISTRATION_SUCCESS':
                # code...
                    die('REGISTRATION_SUCCESS');
                    break;
                case 'REGISTRATION_SUCCESS_EMAIL':
                # code...
                    die('REGISTRATION_SUCCESS_EMAIL');
                    break;
                case false:
                # code...
                    break;
                case true:
                # code...
                    break;
            }
        }
        else {
            $this->layout->view("auth/register");
        }

    }
    function activate() {

    }
    function signin() {

    }
    function signout() {

    }
    function change_password() {

    }
    function forgot_password() {

    }
    function reset_password() {

    }


}

/* End of file auth.php */
/* Location: ./system/application/controllers/auth.php */
